﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace StatusPlan3.UC
{
    /// <summary>
    /// Interaction logic for UCProjectGroups.xaml
    /// </summary>
    public partial class UCProjectGroups : UserControl
    {
        public UCProjectGroups()
        {
            InitializeComponent();
            populateFrame();
        }

        public void populateFrame()
        {
            ProjectGroups pgs = StatusPlanData.statusPlanHandler.getAllProjectGroups();
            projectGroupGridView.ItemsSource = pgs;
        }

        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            Window_ProjectGroup wpg = new Window_ProjectGroup();
            wpg.showNew();
            populateFrame();
            StatusPlanData.mainWindow.populateFrame();
        }

        private void RadButton_Click_1(object sender, RoutedEventArgs e)
        {
            ProjectGroup pg = projectGroupGridView.SelectedItem as ProjectGroup;
            if (pg != null)
            {
                Window_ProjectGroup wpg = new Window_ProjectGroup();
                wpg.showEdit(pg);
                populateFrame();
                StatusPlanData.mainWindow.populateFrame();
            }
        }

        private void projectGroupGridView_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
        {
            ProjectGroup pg = projectGroupGridView.SelectedItem as ProjectGroup;
            if (pg != null)
            {
                Edit_Button.IsEnabled = true;
                Delete_Button.IsEnabled = true;
            }
            else
            {
                Edit_Button.IsEnabled = false;
                Delete_Button.IsEnabled = false;
            }
        }
    }
}
